package com.juc.forkJoinPool.forkJoinPool11;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

public class Run1 {

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		Runnable runnable = new Runnable() {
			
			@Override
			public void run() {
				String newString  = new String();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
			}
		};
		ForkJoinPool pool  = new ForkJoinPool();
		ForkJoinTask<?> task = pool.submit(runnable);
		Thread.sleep(500);
		System.out.println("A = " + pool.isTerminating());
		pool.shutdown();
		System.out.println("B = " + pool.isTerminating());
		System.out.println(task.get());
		Thread.sleep(1000);
	    System.out.println("C = " + pool.isTerminated());
	    //使用shutdown()关闭线程池之前isTerminating()方法返回值一直是false
	}
}
